package sing.cloud.alibaba.seata.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import sing.cloud.alibaba.seata.domain.CommonResult;
import sing.cloud.alibaba.seata.service.IStorageService;

/**
 * @author xing
 * @date 2022/9/4 14:37
 */
@RestController("storageController")
public class StorageController {
    @Autowired
    private IStorageService storageService;

    /**
     * 扣减库存
     */
    @RequestMapping("/storage/decrease")
    public CommonResult decrease(Long productId, Integer count) {
        storageService.decrease(productId, count);
        return new CommonResult(200,"扣减库存成功！");
    }
}
